<?php
/**
 * Created by PhpStorm.
 * User: mt
 * Date: 2018/6/5
 * Time: 15:46
 */

use League\Fractal\Resource\Item;
use League\Fractal\Manager;

function item_model_transform($model, $transformer)
{
    $res =new Item($model, $transformer);
    $manager = new Manager();
    $data = $manager->createData($res)->toArray();
    return $data['data'];
}

function collection_model_transform($model, $transformer)
{
    $res =new \League\Fractal\Resource\Collection($model, $transformer);
    $manager = new Manager();
    $data = $manager->createData($res)->toArray();
    return $data['data'];
}